package com.payment.util;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.function.Supplier;

/**
 * Description:
 *
 * @author weiruibai.vendor
 * Date: 2022/12/12 18:01
 */
@Slf4j
@Service
public class RestSupport<T> {

    public CommonResult<T> get(Supplier<T> supplier) {
        T data = null;
        Integer code;
        try {
            data = supplier.get();
            code = 100;
        } catch (Exception e) {
            log.error("{}", e);
            code = 101;
        }
        return new CommonResult<>(code, data);
    }
}
